<?php
declare (strict_types=1);

namespace app\course\model\cart\admin;

use app\common\model\BaseModel;
use think\model\concern\SoftDelete;

/**
 * Class Cart
 *
 * @package app\course\model\cart\admin
 */
class Cart extends BaseModel
{
    use SoftDelete;

    /**
     * 表名
     *
     * @var string
     */
    protected $name = 'course_cart';

    /**
     * 时间显示格式
     *
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';

    /**
     * 定义表主键
     *
     * @var string
     */
    protected $pk = 'id';

    /**
     * 定义字段类型
     *
     * @var array
     */
    protected $type = [
        'id'        => 'integer',
        'course_id' => 'integer',
    ];

    /**
     * 关联用户
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-06-30
     *
     * @return   [type]                         [description]
     */
    public function user()
    {
        return $this
            ->belongsTo(\app\user\model\user\admin\Account::class, 'user_id')
            ->with(['avatar_url'])
            ->removeOption('soft_delete')
            ->removeWhereField('mhm_id');
    }

}